package cn.tedu.springbootdemo;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Component;

@Component
/**
 * @ConditionalOnMissingBean(name = "gamePhone")
 * 在Phone类型的Bean对象不存在时，才需要创建当前注解所描述的Bean
 *
 * @ConditionalOnBean(User.class)
 * 当User类型对象没有被创建时，MusicPhone类型的对象也不创建
 */
@ConditionalOnMissingBean(name = "gamePhone")
@ConditionalOnBean(User.class)
public class MusicPhone implements Phone{

    public MusicPhone(){
        System.out.println("MusicPhone的构造方法被执行了");
    }
}
